package com.zhanghe.springsecurity.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * TestController
 *
 * @author Clevo
 * @date 2018/3/24
 */
@RestController
public class TestController {

    @GetMapping("/login")
    public String login(Model model, @RequestParam(value = "error", required = false) String error) {
        if (error != null) {
            model.addAttribute("error", "用户名或密码错误");
        }
        return "login";
    }

    @RequestMapping("/test/hello")
    public String helliworld(){
        return "hello world";
    }

    @RequestMapping("/admin/adminurl")
    public String adminurl(){
        return "admin url";
    }

    @RequestMapping("/seller/sellerurl")
    public String sellerurl(){
        return "seller url";
    }
}
